var t = getApp(), n = 0;

Page({
    data: {
        hiddenNo: !1,
        hiddenHas: !0,
        hiddenEnd: !0,
        page:1,
        couponsData:{
            tab:[]
        },
        noMore:false
    },
    onLoad: function() {
        var t = this;
        wx.getStorageSync("token");
          
        t.couponsList(), this.loadingChange();
    },
    couponsList: function() {
        var e = this, a = wx.getStorageSync("token");
        !e.data.noMore && wx.showLoading({
            title: '加载中',
            mask: true,
            success: (result) => {
                
            },
            fail: () => {},
            complete: () => {}
        });
        wx.request({
            url: t.apiUrl("user/conpont"),
            data: {
                type: n,
                page:e.data.page
            },
            method: "post",
            header: {
                "Content-Type": "application/json",
                "X-ECTouch-Authorization": a
            },
            success: function(t) {
                console.log(typeof t.data.data.tab.length);
                if(t.data.data.tab.length == undefined || t.data.data.tab.length == 0){
                    t.data.data.tab = [];
                    e.setData({
                        noMore:true
                    });
                } 
                var page = e.data.page;
                if(page == 1){
                    e.setData({
                        couponsData: t.data.data
                    });
                }else{
                    var coupons_data = e.data.couponsData.tab
                   // coupons_data.concat(t.data.data.tab);
                    e.setData({
                        "couponsData.tab": coupons_data.concat(t.data.data.tab)
                    });
                }
               /*  var coupons_data = e.data.couponsData.tab
                e.data.couponsData.tab.concat(t.data.data.tab);
                e.setData({
                    couponsData: e.data.couponsData
                }); */
            },
            complete:function(){
                setTimeout(function(){
                    wx.hideLoading();
                },1000)      
            }
        });
    },
    loadingChange: function() {
        var t = this;
        setTimeout(function() {
            t.setData({
                hidden: !0
            });
        }, 1e3);
    },
    noUse: function(t) {
        var e = this;
        this.setData({
            hiddenNo: !1,
            hiddenHas: !0,
            hiddenEnd: !0,
            page:1,
            noMore:false
        }), n = t.currentTarget.dataset.index, e.couponsList();
    },
    hasUse: function(t) {
        var e = this;
        this.setData({
            hiddenNo: !0,
            hiddenHas: !1,
            hiddenEnd: !0,
            page:1,
            noMore:false
        }), n = t.currentTarget.dataset.index, e.couponsList(), e.loadingChange();
    },
    useEnd: function(t) {
        var e = this;
        this.setData({
            hiddenNo: !0,
            hiddenHas: !0,
            hiddenEnd: !1,
            page:1,
            noMore:false
        }), n = t.currentTarget.dataset.index, e.couponsList(), e.loadingChange();
    },
    onPageScroll:function(e) {
        console.log(e);
    },
    onReachBottom:function(e) {
        var page = this.data.page;
        page++;
        this.setData({
            page:page
        });
        this.couponsList();
    }
      
});